import {
	get,
	post
} from 'utils/requests'

/* 获取用户地址 */
export const getUserAddress = () => post({
	// url: '/wx/user/getSelfShoppingAddress',
	url: '/applet/mine/address/getMyAddress'
})

/* 删除用户地址 */
export const delUserAddress = id => post({
	url: '/applet/mine/address/delAddressById',
	data:{
		id
	}
})

/* 修改或添加用户地址 */
export const setUserAddress = (addressInfo) => {
	// 如果id存在，则是修改地址，如果id不存在则是添加地址
	const url = addressInfo.id?"/applet/mine/address/modifyAddress":"/applet/mine/address/addAddress";
	return post({
		url,
		json:"json",
		data:addressInfo,
		loading: true
	})
}

/* 修改默认用户地址 */
export const setDefaultUserAddress = (id) => {
	// 如果id存在，则是修改地址，如果id不存在则是添加地址
	const url = "/applet/mine/address/modifyDefaultAddress";
	return post({
		url,
		data:{id}
	})
}